//
//  LeaderboardFromTableViewCell.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/12.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "LeaderboardFromTableViewCell.h"

@implementation LeaderboardFromTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self.contentView addSubview:self.userHeadView];
        [self.contentView addSubview:self.ranking];
        [self.userHeadView addSubview:self.userHead];
        [self.contentView addSubview:self.userName];
        [self.contentView addSubview:self.numberLab];
        [self showLeaderboardCell];
    }
    return self;
}

- (void)showLeaderboardCell
{
    _ranking.sd_layout
    .topSpaceToView(self.contentView,kHeightScale(22))
    .leftSpaceToView(self.contentView,kWidthScale(10))
    .widthIs(kWidthScale(25))
    .heightIs(kHeightScale(25));
    
    _userHeadView.sd_layout
    .topSpaceToView(self.contentView,kHeightScale(9))
    .leftSpaceToView(self.ranking,kWidthScale(5))
    .widthIs(kWidthScale(45))
    .heightIs(kHeightScale(45));
    
    _userHead.sd_layout
    .topSpaceToView(self.userHeadView,kHeightScale(5))
    .leftSpaceToView(self.userHeadView,kWidthScale(5))
    .rightSpaceToView(self.userHeadView,kWidthScale(5))
    .bottomSpaceToView(self.userHeadView,kHeightScale(5));
    
    _userName.sd_layout
    .centerYEqualToView(self.userHeadView)
    .leftSpaceToView(self.userHeadView,kWidthScale(7))
    .widthIs(kWidthScale(105))
    .heightIs(kHeightScale(25));
    
    _numberLab.sd_layout
    .topEqualToView(self.userName)
    .rightSpaceToView(self.contentView,kWidthScale(15))
    .widthIs(kWidthScale(50))
    .heightIs(kHeightScale(25));
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (UIButton *)ranking
{
    if (!_ranking)
    {
        _ranking = [UIButton buttonWithType:UIButtonTypeCustom];
        [_ranking setBackgroundImage:[UIImage imageNamed:@"xing"] forState:0];
        [_ranking setTitle:@"4" forState:0];
        [_ranking setTitleColor:[UIColor whiteColor] forState:0];
    }
    return _ranking;
}

- (UIButton *)userHead
{
    if (!_userHead)
    {
        _userHead = [UIButton buttonWithType:UIButtonTypeCustom];
        [_userHead setImage:[UIImage imageNamed:@"toixiang"] forState:0];
        [_userHead setBackgroundColor:[UIColor colorWithWhite:0.8 alpha:0.4]];
        _userHead.layer.cornerRadius = kWidthScale(18);
        _userHead.layer.masksToBounds = YES;
    }
    return _userHead;
}

- (KQlable *)userName
{
    if (!_userName)
    {
        _userName = [[KQlable alloc] init];
        _userName.text = @"朱朱朱";
        _userName.textColor = [UIColor colorWithHexString:@"#333333"];
        _userName.font = [UIFont systemFontOfSize:kHeightScale(15)];
    }
    return _userName;
}

- (UILabel *)numberLab
{
    if (!_numberLab)
    {
        _numberLab = [[UILabel alloc] init];
        _numberLab.text = @"12次";
    }
    return _numberLab;
}

- (UIView *)userHeadView
{
    if (!_userHeadView)
    {
        _userHeadView = [[UIView alloc] init];
        _userHeadView.backgroundColor = [UIColor colorWithHexString:@"#dddddd"];
        _userHeadView.layer.cornerRadius = kHeightScale(21);
        _userHeadView.layer.masksToBounds = YES;
    }
    return _userHeadView;
}

@end
